/******************************************************************
 * This program was written as part of
 *   Assignment 4
 *   Computer Graphics                                             
 *   Semester 1, 2013
 *   School of Computer Science,
 *   The University of Adelaide
 *                                                                          
 * I declare that all material in this assessment is my own work except where
 * there is clear acknowledgement and reference to the work of others. I have
 * read the University Policy Statement on Plagiarism, Collusion and Related
 * Forms of Cheating:  

 * http://www.adelaide.edu.au/policies/?230

 * I give permission for my assessment work, including my subversion
 * repository, to be reproduced and submitted to academic staff for the
 * purposes of assessment and to be copied, submitted and retained in a form
 * suitable for electronic checking of plagiarism.  
                            
 * Authors:
 *  Terry Moschou    a1208955
 *  Salih Al-Rashid  a1210108
 *  Ben McAleer      a1212203
*******************************************************************/

#ifndef FIRE_HPP
#define FIRE_HPP
#include "Common.hpp"
#include "Object.hpp"
#include "UserInterface.hpp"
class Material;

class Fire : public Object
{
public:
  Fire(Object * parent, glm::mat4 modelMatrix);
  
  virtual void draw(const glm::mat4 & modelMatrix);
  
private:
  
  /*
   * Update pass (ni rasterisation)
   *      input                   output
   *   A ------> [Vertex Shader] -------> B
   * 
   * Render pass
   *      input                   to frag shader
   *   B ------> [Vertex Shader] ---------------> 
   */
  
  enum Attribute {
    VertexPosition,
    StartTime,
    VertexVelocity,
    NumAttribs
  };
  
  enum Buffers {
    A,
    B,
    NumPasses
  };
  
  Buffers m_updateBuffer;
  Buffers m_renderBuffer;
  
  GLuint m_vboHandles[NumPasses * NumAttribs];
  GLuint m_vboInitVel;
  GLuint m_tfoHandles[NumPasses]; // transform feedback objects
  GLuint m_vaoHandles[NumPasses];
  
  GLuint m_query;
  //int    m_drawBuf; // index to m_tfoHandle, toggles between 0 and 1
  
  //Material * m_material;
  
  int m_nParticles;
  int m_elapsedTime;
  float m_rate;
  
  GLint m_al_Position0;
  GLint m_al_Position1;
  GLint m_al_Velocity0;
  //GLint m_al_Velocity1;
  GLint m_al_StartTime0;
  GLint m_al_StartTime1;
  GLint m_al_InitVel0;
  //GLint m_al_InitVel1;
  
  //GLint m_al_texCoord;

  GLint m_ul_model;
  
  GLint m_ul_time0;
  GLint m_ul_time1;
  GLint m_ul_deltaTime;
  GLint m_ul_accel;
  GLint m_ul_lifeTime0;
  GLint m_ul_lifeTime1;
 
  float m_lifeTime;
  glm::vec3 m_accel;
  //GLint m_ul_texMap;
  //GLint m_ul_updateSub;
  
}; 
#endif //FIRE_HPP














